package com.wl.designpattern.visitor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 创建对象结构
 * Created by wangliang on 2021/2/27.
 */
public class Websites {
    List<Web> list = new ArrayList<>();//元素集合

    public void accept(Visitor visitor) {
        Iterator<Web> iterator = list.iterator();
        while (iterator.hasNext()) {//迭代遍历访问
            iterator.next().accept(visitor);
        }
    }

    public void addWeb(Web web) {
        list.add(web);
    }
}
